﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class InputCheck : MonoBehaviour
{
    public InputField[] inputChecks;
    public string[] keys;
    public GameObject lastStep = null;
    public GameObject nextStep=null;
    public Text tip;
    public Button checkBtn;

    public UnityEvent finishEvent;

    private void Start()
    {
        checkBtn.onClick.AddListener(Check);
    }

    public void Check()
    {
        int index = 0;
        for (int i = 0; i < inputChecks.Length; i++)
        {
            if (inputChecks[i].text.Contains(keys[i]))
            {
                index++;
            }
        }

        if (index >= inputChecks.Length)
        {
            if (nextStep != null)
            {
                nextStep.SetActive(true);
                lastStep.SetActive(false);
            }
            else
            {
                finishEvent.Invoke();
            }
        }
        else
        {
            tip.text = "填写有误，请核查";
            tip.gameObject.SetActive(true);
        }
    }

}
